package org.game.db.vo;

import com.sojoys.artifact.tools.ToolMap;
import org.cfg.RoomCfg;
import org.cfg.cache.DiscreteDataCfgCache;
import org.cfg.cache.RoomCfgCache;
import org.constant.DiscreteDataID;
import org.constant.DiscreteDataKey;
import org.constant.smallkey.GoodInfoMapSmallKey;
import org.game.db.bean.Item;

import java.util.Map;

/**
 * 房间
 * Created by fxf on 2018-3-10.
 */
public class RoomVO extends Item {

    public RoomVO(long id, int num, int cid, Map info, int playerId) {
        super(id, num, cid, info, playerId);
    }

    public long getRoleId(){
        return ToolMap.getLong(GoodInfoMapSmallKey.ROLE_ID, getInfo());
    }

    public void setRoleId(long roleId){
        if (!isDefaultRoom()){
            getInfo().put(GoodInfoMapSmallKey.ROLE_ID, roleId);
        }
    }

    public RoomCfg getCfg(){
        return RoomCfgCache.me().getById(getCid());
    }

    /**
     * 是否默认房间，默认房间不属于任何看板娘
     */
    public boolean isDefaultRoom(){
        return getCfg().getId() == DiscreteDataCfgCache.me().getIntData(DiscreteDataID.ROLE, DiscreteDataKey.DEFAULT_ROOM);
    }

}
